import request from '@/utils/request'

const api = {
  page: '/unitInfo/page',
  list: '/unitInfo/list',
  unitInfo: '/unitInfo'
}

export function getUnit (parameter) {
  return request({
    url: api.page,
    method: 'get',
    params: parameter
  })
}

export function getUnitList (parameter) {
  return request({
    url: api.list,
    method: 'get',
    params: parameter
  })
}

export function saveUnit (parameter) {
  return request({
    url: api.unitInfo,
    method: parameter.id === 0 ? 'post' : 'put',
    data: parameter
  })
}

export function deleteUnit (parameter) {
  return request({
    url: api.unitInfo + `/${parameter.id}`,
    method: 'delete'
  })
}
